home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / LIBRARY / RTPC10 / VGA_D.PAS < prev    next >
Pascal/Delphi Source File  |  1993-11-20  |  3KB  |  93 lines

  1. {
  2.   ┌────────┬──────────────────────────────────────────────────────┐
  3.   │Name    │ VGA_D.PAS                                            │
  4.   ├────────┼──────────────────────────────────────────────────────┤
  5.   │Use     │ Example program using VGA.TPU                        │
  6.   ├────────┼──────────────────────────────────────────────────────┤
  7.   │By      │ Rafe Aldridge - (C) Copyright 1993                   │
  8.   └────────┴──────────────────────────────────────────────────────┘
  9.  
  10.   ┌───────────────────────────────────────────────────────────────┐
  11.   │ Rafe's TP Collection is SHAREWARE                             │
  12.   ├───────────────────────────────────────────────────────────────┤
  13.   │                                                               │
  14.   │ If you find any part of Rafe's TP Collection usefull then     │
  15.   │ please become a registered user by sending 10 Pounds Sterling │
  16.   │ to the address below. In return you will recieve the LATEST   │
  17.   │ FULL source code to ALL the units as well anything new.       │
  18.   │                                                               │
  19.   │ Please feel free to write with suggestions, ideas or money to │
  20.   │     Rafe Aldridge,                                            │
  21.   │     Street Farm,                                              │
  22.   │     Dereham Road,                                             │
  23.   │     Garvestone,                                               │
  24.   │     Norfolk.                                                  │
  25.   │     NR9 4QT                                                   │
  26.   │     ENGLAND                                                   │
  27.   │                                                               │
  28.   └───────────────────────────────────────────────────────────────┘
  29. }
  30.  
  31. {$R-,S-,D-,L-}
  32.  
  33. uses vga,crt;
  34.  
  35. type
  36.    star = record
  37.              sx,sy    : word;  { posistion on real screen }
  38.              dx,speed : real; { posistion in "space" and speed }
  39.           end;
  40.  
  41. const
  42.   noof_stars = 50;
  43.  
  44. procedure main;
  45. var
  46.   stars : array [1..noof_stars] of star;
  47.   z : word;
  48. begin
  49.  
  50.   for z:=1 to noof_stars do { randomize stars }
  51.     with stars[z] do
  52.       begin
  53.         sx:=random (319); { start anywhere }
  54.         sy:=random (199); { start at random height }
  55.         dx:=sx;
  56.         speed:=(random(99)+10)/99; { randomize speed }
  57.       end;
  58.  
  59.   openvga;
  60.  
  61.   repeat
  62.     for z:=1 to noof_stars do
  63.       with stars[z] do
  64.         begin
  65.           dx:=dx-speed; { move star }
  66.  
  67.           if round(dx)<sx then { does it need replotting ? }
  68.             begin
  69.               putpixel (sx,sy,0); { delete old star }
  70.               sx:=round(dx);      { move star }
  71.               if sx<1 then        { has star moved off screen }
  72.                 begin
  73.                   sx:=319;          { start at far left }
  74.                   dx:=319;
  75.                   sy:=random (199); { and at a random height }
  76.                 end; { sx<1 }
  77.              putpixel (sx,sy,15); { redraw star }
  78.             end; { round(dx)<sx }
  79.         end; { with + for }
  80.   until keypressed;
  81.  
  82.   closevga;
  83.  
  84. end;
  85.  
  86.  
  87. begin
  88.   if isvga then
  89.     main
  90.   else
  91.     writeln ('This program requires vga');
  92. end.
  93.